<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>权限指派</title>
<jsp:include page="/common.jsp" />
<script type="text/javascript">
function doAssign(){
	var id=$("#lister").jqGrid('getGridParam','selarrrow');
	id=id.toString();
	if (id===""||id.split(",").length==0) {
		$.messager.alert('警告','请选择一条记录！','warning');
		return;
	}
	var userid=$("#user_id").val();
	if(!userid ||userid==""){
		$.messager.alert('警告','请先选定用户！','warning');
		return;
	}
	var url = "${pageContext.request.contextPath}/system/user/assign.htm?beanIds="
		+ id
		+ "&bean.id="
		+ userid
		+ "&tmp="+new Date();
	
	$.get(
				url,
				function(response) {
					rst = response;
					switch (rst) {
					case '0':
						//$.messager.alert("提示","指派失败!","info");
						$.messager.show({title:'提示',msg:'指派失败!',timeout:'0'});
						break;
					case '1':
						$.messager.show({title:'提示',msg:'指派成功!',timeout:'10'});
						//$.messager.alert("提示","指派成功!","info");
						break;
					}

				});
}
</script>
</head>

<body>
	<table cellpadding="0" cellspacing="0" width="100%" height="100%">
		<tbody>
			<tr>
				<td>
					<div class="toolbar" style="background-color: #e0e0e0;">
					   <a plain="true" href="javascript:void(0);"
							class="easyui-linkbutton" iconCls="icon-ok" onclick="doAssign();">确定</a>
					</div><input type="hidden" id="user_id" value="${ formBean.bean.id}">
				</td>
			</tr>
			
			<tr>
				<td height="100%" valign="top" width="100%">
					<table id="lister" name="lister" style="width:100%;height:100%"></table>
					<div id="pager"></div>
				</td>
			</tr>
		</tbody>
	</table>
	<div id='win' class='easyui-window' title='New Window' style='width:400px;height:300px;padding:5px;' closed='true'>
	</div>
	<script>
	 $(document).ready(function(){
    	 $("#lister")
			.jqGrid(
					{
						url : "${pageContext.request.contextPath }/security/role/listBy.htm",
						datatype : "json",
						colNames : [ '权限组编号','权限名称'],
						colModel : [ 
									{name : 'id',index : 'role_id',searchtype:"number"}, 
									{name : 'roleName',index : 'role_name'}
									],
						rowNum : 10,
						shrinkToFit: true,
						rowList : [ 10, 20, 30 ],
						pager : '#pager',
						sortname : 'role_id',
						viewrecords : true,
						sortorder : "asc",
						caption : "权限列表",
						mtype: "POST",
						multiselect: true,
						autowidth:true
					});
		$("#lister").jqGrid('navGrid','#pager', {edit : false,add : false,del : false});
      });
	</script>
</body>
</html>